import { createSlice } from '@reduxjs/toolkit'

const userStore = createSlice({
  name: 'user',
  initialState: {
    token: ''
  },
  reducers: {
    setToken(state, action) {
      console.log(action, '----')
      state.token = action.payload
      localStorage.setItem('token', action.payload)
    }
  }
})

const { setToken } = userStore.actions

const userReducer = userStore.reducer

export { setToken }
export default userReducer
